package com.yiyuan.system.action;

import javax.annotation.Resource;

import com.yiyuan.common.base.BaseAction;
import com.yiyuan.system.model.User;
import com.yiyuan.system.service.ISystemService;

public class LoginAction extends BaseAction {
	private static final long serialVersionUID = 1L;

	private String userName;
	private String password;
	private String info;

	// 资源引用
	@Resource
	private ISystemService systemService;

	/** ******************************************* */
	public String login() throws Exception {
		User user = this.systemService.getUserByNameAndPwd(userName, password);
		if (user == null) {
			this.info="用户名或密码错误，请您重新登录！";
			return "toLogin";
		} else {
			this.session.put("user", user);
		}
		return "toMain";
	}

	public String logout() {
		this.info="您已经安全退去系统，如继续使用，请重新登录！";
		return "toLogout";
	}

	public String exit(){
		this.session.clear();
		this.info="您已经安全退去系统，如继续使用，请重新登录！";
		return "toExit";
	} 
	/** ********************************************* */
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getInfo() {
		return info;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	
}
